﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StoreTransport.Data {
    
    public class ProductKindData : AbstractProductData {
        public int ProductKindId { get; set; }
        public string ProductKindName { get; set; }
        // field temp use to calculate
        public int ComputedStableProducts { get; set; }
        public int ComputedMinProducts { get; set; }
        public int ComputedMaxProducts { get; set; }
        public Dictionary<int, ProductData> DicProducts { set; get; }
        public int SumCurrentQuatity {
            get {
                return DicProducts.Values.Sum(c => c.ComputedInventory);
            }

        }

        public ProductKindData() {
            DicProducts = new  Dictionary<int, ProductData>();
        }

        // use to devive code in product kind.
        public List<ProductData> GetPriorityList(bool islack) {
            if (islack) {
                return DicProducts.Values.OrderBy(rr => rr.ImportInventory).ToList();
            }
            return DicProducts.Values.OrderByDescending(rr => rr.ImportInventory).ToList();
        }
    }
}
